
//技能效果

package net.sf.odinms.net.channel.handler;

import net.sf.odinms.client.MapleClient;
import net.sf.odinms.client.skills.*;
import net.sf.odinms.net.AbstractMaplePacketHandler;
import net.sf.odinms.server.TimerManager;
import net.sf.odinms.server.life.MapleMonster;
import net.sf.odinms.server.maps.MapleMap;
import net.sf.odinms.tools.MaplePacketCreator;
import net.sf.odinms.tools.data.input.SeekableLittleEndianAccessor;

public class SkillEffectHandler extends AbstractMaplePacketHandler {

    @Override
    public void handlePacket(SeekableLittleEndianAccessor slea, final MapleClient c) {
        System.out.println("SkillEffect："+slea.toString());
        int skillId = slea.readInt();//技能ID
        int level = slea.readByte();//等级
        byte flags = slea.readByte();//80
        int speed = slea.readByte();//武器攻击速度
        int op = slea.readByte();

        //暴风箭雨 金属风暴 磁石
        if ((skillId == 弓手.暴风箭雨 
                || skillId == 枪手.金属风暴
                || skillId == 勇士.磁石 /*|| skillId == 1221001 圣骑士磁石取消*/
                || skillId == 龙骑.磁石
                || skillId == 火毒.创世之破
                || skillId == 冰雷.创世之破
                || skillId == 牧师.创世之破
                || skillId == 火毒.末日烈焰
                || skillId == 刀飞.转化术
                || skillId == 弩手.穿透箭
                || skillId == 拳手.贯骨击
                || skillId == 奇袭者.贯骨击
                || skillId == 枪手.投弹攻击
                || skillId == 夜行者.毒炸弹
                || skillId == 风灵使者.暴风箭雨
                || skillId == 龙神.冰点寒气 //冰点寒气
                || skillId == 龙神.火焰喷射 //火焰喷射
                || skillId == 双刀.终极斩  //终极斩
                || skillId == 双刀.怪物炸弹  //怪物炸弹
                || skillId == 弩骑.吞噬 //弩骑 吞噬
                || skillId == 弩骑.奥义箭乱舞 //弩骑 奥义箭乱舞
                || skillId == 机械师.火焰喷射器 //火焰喷射器
                || skillId == 机械师.强化火焰喷射器
                //头上有能量条
                ) && level >= 1) {
            c.getPlayer().getMap().broadcastMessage(c.getPlayer(), MaplePacketCreator.skillEffect(c.getPlayer(), skillId, level, flags, speed, op), false);
            /*
            if(skillId == 弩骑.吞噬) {
                final int mobid = slea.readInt();//被吞噬的怪的Object id
                final MapleMonster monster = c.getPlayer().getMap().getMonsterByOid(mobid);
                TimerManager tMan = TimerManager.getInstance();
                tMan.schedule(new Runnable() {
                    public void run() {
                        //MapleMap ret = new MapleMap();//定义角色效果
                        //ret.spawnedMonstersOnMap.decrementAndGet();
                        //monster.setHp(0);
                        //monster.getMap().broadcastMessage(MaplePacketCreator.SpecialKillMonster(monster.getObjectId(), c.getPlayer().getId()));
                        //c.getPlayer().getMap().removeMapObject(mobid);
                        //monster.killBy(c.getPlayer()); 
                        c.getPlayer().getMap().killMonster2(monster, c.getPlayer());
                    }
                }, 800);
            }
             */
            if(skillId == 弩骑.吞噬) {
                c.getPlayer().设置吞噬的怪id(slea.readInt());
            }
        } else {
            System.out.println("SkillEffectHandler要添加相应的skillid"+skillId);
            c.getSession().close();
            return;
        }
    }
}